//
//  NoticeDetailViewController.swift
//  ModernFoodWebsite
//
//  Created by apple on 16/5/30.
//  Copyright © 2016年 Lonnie. All rights reserved.
//

import UIKit

class NoticeDetailViewController: BaseTableViewController {
    let scrollView = UIScrollView()
    let avatarImageView = UIImageView()
    let nicknameLabel = UILabel()
    let timeLabel = UILabel()
    let skipImageView = UIImageView(image:UIImage(named: "icon_skip"))
    let titleLabel = UILabel()
    let readCountImageView = UIImageView(image:UIImage(named: "icon_readcount_highlighted"))
    let readCountLabel = UILabel()
    let commentImageView = UIImageView(image:UIImage(named: "icon_leavemessage"))
    let commentLabel = UILabel()
    let tagsContentView = UIView()
    let contentLabel = UILabel()
    let contentImageView = UIImageView()
    
    var collectItem = UIBarButtonItem()
    var shareItem = UIBarButtonItem()
    var someItem = UIBarButtonItem()
    
    override func viewDidLoad() {
        super.viewDidLoad()
        addCommonStyleBackItem()
        view.addSubview(scrollView)
        scrollView.snp_makeConstraints { make in
            make.edges.equalTo(self.view)
        }
        scrollView.addSubviews([avatarImageView,nicknameLabel,timeLabel,skipImageView,titleLabel,readCountImageView,readCountLabel,commentImageView,commentLabel,tagsContentView,contentLabel,contentImageView])
        
        avatarImageView.snp_makeConstraints { make in
            make.leading.equalTo(self.scrollView).offset(20)
            make.top.equalTo(self.scrollView).offset(17)
            make.size.equalTo(CGSizeMake(40, 40))
        }
        avatarImageView.layer.cornerRadius = 20
        avatarImageView.layer.masksToBounds = true
        avatarImageView.image = UIImage(named: "information_pic1")
        nicknameLabel.snp_makeConstraints { make in
            make.leading.equalTo(self.avatarImageView.snp_trailing).offset(14.5)
            make.bottom.equalTo(self.avatarImageView.snp_centerY).offset(-4)
        }
        nicknameLabel.text = "月面兔手柄起米娜"
        timeLabel.snp_makeConstraints { make in
            make.leading.equalTo(self.avatarImageView.snp_trailing).offset(14.5)
            make.top.equalTo(self.avatarImageView.snp_centerY).offset(4)
        }
        
        titleLabel.text = "12.12 20:99"
        skipImageView.snp_makeConstraints { make in
            make.centerY.equalTo(avatarImageView)
            make.trailing.equalTo(self.scrollView).offset(-20)
        }
        
        titleLabel.numberOfLines = 0
        titleLabel.snp_makeConstraints { make in
            make.top.equalTo(self.scrollView).offset(68)
            make.centerX.equalTo(self.scrollView)
            make.width.equalTo(self.scrollView).offset(-40)
        }
        titleLabel.text = "供应方形食用菌灭菌器蘑菇灭菌器平菇培养基灭菌器专业制造"
        
        readCountImageView.snp_makeConstraints { make in
            make.leading.equalTo(self.avatarImageView)
            make.top.equalTo(self.titleLabel.snp_bottom).offset(14)
        }
        readCountLabel.snp_makeConstraints { make in
            make.leading.equalTo(self.readCountImageView.snp_trailing).offset(5)
            make.centerY.equalTo(self.readCountImageView)
        }
        readCountLabel.text = "222"
        commentImageView.snp_makeConstraints { make in
            make.leading.equalTo(self.readCountLabel.snp_trailing).offset(20)
            make.centerY.equalTo(self.readCountImageView)
        }
        commentLabel.snp_makeConstraints { make in
            make.leading.equalTo(self.commentImageView.snp_trailing).offset(5)
            make.centerY.equalTo(self.readCountImageView)
        }
        commentLabel.text = "111"
        tagsContentView.snp_makeConstraints { make in
            make.leading.equalTo(self.scrollView).offset(20)
            make.top.equalTo(self.readCountImageView.snp_bottom).offset(13.5)
            make.width.equalTo(self.scrollView).offset(-40)
        }
        
        contentLabel.snp_makeConstraints { make in
            make.centerX.equalTo(self.scrollView)
            make.width.equalTo(self.scrollView).offset(-40)
            make.top.equalTo(self.tagsContentView.snp_bottom).offset(10)
        }
        contentLabel.numberOfLines = 0
        contentLabel.text = "固体饮料面向全国招商\n  杭州口非口力食品有限公司，坐落在拥有天堂美誉的杭州，是国内专业的速溶 饮料生产企业。公司凭着多年的全自动咖啡饮料机，投币咖啡机及相关原材料的运营经验调配出专业的速溶饮料，公司推出的咖啡、奶茶、果汁及豆奶等系列产品一 经推出备受广大代理商和消费者的信赖。口非口力饮品，精选优质原料精心调配，无论是口味还是出杯量都能做到同行领先水平。\n  公司成立以来一直致力于打造成中国热饮料行业市场龙头品牌，严格把控所有原材料的食品安全质量，坚持以最优质的原料打造最具性价比的产品。公司 在提供优质产品的基础上不忘增强服务意识，打造良好的企业信誉。在国家提倡食品安全大背景下不断追求顾客的满意，打造优质，健康的饮品是我们公司的目标。\n  质量是企业的生命，诚信是企业的动力，选择口非口力就是选择了您所需要的基础!真诚期待与新老客户的合作!(朱先生：15268828010 0571-88749160 QQ：276454096)\n  "
        contentImageView.snp_makeConstraints { make in
            make.centerX.equalTo(self.scrollView)
            make.width.equalTo(self.scrollView).offset(-40)
            make.top.equalTo(self.contentLabel.snp_bottom).offset(10)
            make.bottom.equalTo(self.scrollView).offset(-10)
        }
        contentImageView.image = UIImage(named:"information_pic1")
        
        someItem = UIBarButtonItem(image: UIImage(named: "icon_leavemessage"), style: .Plain, target: self, action: #selector(NoticeDetailViewController.some))
        self.navigationItem.rightBarButtonItems = [someItem]
        
        tagsContentView.addTags(["粮食加工","广东"])
    }
    
    func some() {
        performSegueWithIdentifier("publish", sender: nil)
    }
}
